package utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.print.attribute.AttributeSet;
import javax.xml.*;

import utils.XMLParser.IllegalCharacterException;
import utils.XMLParser.XmlParserCallback;

public class XMLReader implements XmlParserCallback {
	  public XMLReader() {
	    super();
	  }
	  public void read(InputStream is) throws IOException,
	                                 IllegalCharacterException {
	    XMLParser parser = new XMLParser(this);
	    BufferedReader r = new BufferedReader(new InputStreamReader(is));
	    String line = r.readLine();
	    while (line != null) {
	      parser.parse(line);
	      line = r.readLine();
	    }
	    r.close();
	  }
	  public void handleStartTag(String tagName, AttributeSet a) {
	    System.out.println("start tag " + tagName);
	  }
	  public void handleEndTag(String tagName) {
	    System.out.println("end tag " + tagName);
	  }
	  public void handleText(String text) {
	    if(text != null && text.trim().length() > 0) {
	      System.out.println("text " + text);
	    }
	  }
	@Override
	public void handleStartTag(String tagName, javax.swing.text.AttributeSet a) {
		// TODO Auto-generated method stub
		
	}
	}
